package nuig.prolog.userTypingFormat.impl;

import nuig.prolog.PrologAccess.impl.MeaningProcess;
import nuig.prolog.PrologAccess.impl.NormalSentenceProcess;
import nuig.prolog.entity.WordEntity;
import nuig.prolog.userTypingFormat.Rule;

public class NormalSentenceRule extends Rule {

	@Override
	public Rule DoRule() throws Exception {

		NormalSentenceProcess normalSentenceProcess = new NormalSentenceProcess();

		if (normalSentenceProcess.isSuccess(GetString())) {

			//ReturnMessage.append("I understand this is a Normal sentence.");
			// meaning process
			MeaningProcess mean = new MeaningProcess();

			String keyWords = "";
			String People = "";

			for (WordEntity word : ProcessList) {
				if (word.getType().equals("est")) {
					keyWords = word.getWord();
				}

				if (word.getType().equals("people")) {
					People = word.getWord();
				}
			}

			String plcode = keyWords + "(" + People + ").";
			 if(mean.isSuccess(plcode))
			 {
				 ReturnMessage.append("yes,"+People+" is the "+keyWords);
			 }else
			 {
				 ReturnMessage.append("no,"+People+" is not the "+keyWords);
			 }

		} else {

		}

		return this;

	}

}
